package com.smartlbs.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smartlbs.baseframe.web.ResponseInfo;
import com.smartlbs.dto.PayLogDto;
import com.smartlbs.entity.UserBasic;
import com.smartlbs.service.IPayLogService;


/**
 * 订单基本信息控制层实现类
 * 
 * 
 *
 */
@Controller
@RequestMapping("pay/log")
public class PayLogController {
	
	@Autowired
	private IPayLogService payLogService;
	
	/**
	 * 获取消费信息
	 * 
	 * 
	 * 
	 * @param request
	 * @param code
	 * @return
	 */
	@RequestMapping("find")
	@ResponseBody
	public ResponseInfo find(HttpServletRequest request, Integer pageNo, Integer pageSize, PayLogDto payLogDto){
		//
		int result = 0;
		String message = "";
		Object data = null;
		
		pageNo = pageNo == null?1:pageNo;
		pageSize = pageSize == null?10:pageSize;
		
		if(payLogDto.getUserId() != null && payLogDto.getUserId() == 0){
			UserBasic userBasic = (UserBasic)request.getAttribute("currentUser");
			payLogDto.setUserId(userBasic.getUserId());
		}
		
		try {
			data = payLogService.find(pageNo, pageSize, payLogDto);
			
			result = 1;
			message = "数据获取成功";
		} catch (Exception e) {
			message = "数据获取失败";
			e.printStackTrace();
		}
		
		/*
		 * 返回值信息
		 */
		ResponseInfo responseInfo = new ResponseInfo();
		
		responseInfo.setResult(result);
		responseInfo.setMessage(message);
		responseInfo.setData(data);
		
		return responseInfo;
	}
}